1 /*
2 
3 Boost Software License - Version 1.0 - August 17th, 2003
4 
5 Permission is hereby granted, free of charge, to any person or organization
6 obtaining a copy of the software and accompanying documentation covered by
7 this license (the "Software") to use, reproduce, display, distribute,
8 execute, and transmit the Software, and to prepare derivative works of the
9 Software, and to permit third-parties to whom the Software is furnished to
10 do so, all subject to the following:
11 
12 The copyright notices in the Software and this entire statement, including
13 the above license grant, this restriction and the following disclaimer,
14 must be included in all copies of the Software, in whole or in part, and
15 all derivative works of the Software, unless such copies or derivative
16 works are solely in the form of machine-executable object code generated by
17 a source language processor.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
22 SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
23 FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
24 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 DEALINGS IN THE SOFTWARE.
26 
27 */ 
28 
29 module derelict.glib.gtestutils;
30 
31 import derelict.glib.gtypes;
32 import derelict.glib.glibconfig;
33 import derelict.glib.gmessages;
34 import derelict.glib.gslist;
35 import derelict.glib.gstring;
36 import derelict.glib.gquark;
37 import derelict.glib.gerror;
38 import core.stdc.config;
39 import core.stdc.string;
40 
41 extern (C):
42 
43 alias void function () GTestFunc;
44 alias void function (const(void)*) GTestDataFunc;
45 alias void function (void*, const(void)*) GTestFixtureFunc;
46 alias _Anonymous_0 GTestTrapFlags;
47 alias _Anonymous_1 GTestConfig;
48 alias _Anonymous_2 GTestLogType;
49 alias _Anonymous_3 GTestLogMsg;
50 alias _Anonymous_4 GTestLogBuffer;
51 alias int function (const(char)*, GLogLevelFlags, const(char)*, void*) GTestLogFatalFunc;
52 
53 version(Derelict_Link_Static)
54 {
55     //extern( C ) nothrow 
56     //{
57     //    const GTestConfig* g_test_config_vars;
58     //}
59 }
60 else
61 {
62     extern( C ) nothrow 
63     {
64         alias da_g_test_config_vars = const GTestConfig*;
65     }
66 
67     __gshared
68     {
69         da_g_test_config_vars g_test_config_vars;
70     }
71 }
72 
73 
74 enum _Anonymous_0
75 {
76 	G_TEST_TRAP_SILENCE_STDOUT = 128,
77 	G_TEST_TRAP_SILENCE_STDERR = 256,
78 	G_TEST_TRAP_INHERIT_STDIN = 512
79 }
80 
81 enum _Anonymous_2
82 {
83 	G_TEST_LOG_NONE = 0,
84 	G_TEST_LOG_ERROR = 1,
85 	G_TEST_LOG_START_BINARY = 2,
86 	G_TEST_LOG_LIST_CASE = 3,
87 	G_TEST_LOG_SKIP_CASE = 4,
88 	G_TEST_LOG_START_CASE = 5,
89 	G_TEST_LOG_STOP_CASE = 6,
90 	G_TEST_LOG_MIN_RESULT = 7,
91 	G_TEST_LOG_MAX_RESULT = 8,
92 	G_TEST_LOG_MESSAGE = 9
93 }
94 
95 struct _Anonymous_1
96 {
97 	gboolean test_initialized;
98 	gboolean test_quick;
99 	gboolean test_perf;
100 	gboolean test_verbose;
101 	gboolean test_quiet;
102 	gboolean test_undefined;
103 }
104 
105 struct _Anonymous_3
106 {
107 	GTestLogType log_type;
108 	guint n_strings;
109 	gchar** strings;
110 	guint n_nums;
111 	real* nums;
112 }
113 
114 struct _Anonymous_4
115 {
116 	GString* data;
117 	GSList* msgs;
118 }
119 
120 struct GTestCase;
121 
122 
123 struct GTestSuite;
124 
125 
126 version(Derelict_Link_Static)
127 {
128     extern( C ) nothrow 
129     {
130         int g_strcmp0(const(char)* str1, const(char)* str2);
131         void g_test_minimized_result(double minimized_quantity, const(char)* format, ...);
132         void g_test_maximized_result(double maximized_quantity, const(char)* format, ...);
133         void g_test_init(int* argc, char*** argv, ...);
134         int g_test_run();
135         void g_test_add_func(const(char)* testpath, GTestFunc test_func);
136         void g_test_add_data_func(const(char)* testpath, gconstpointer test_data, GTestDataFunc test_func);
137         void g_test_add_data_func_full(const char *testpath, gpointer test_data, GTestDataFunc test_func, GDestroyNotify data_free_func);
138         void g_test_fail();
139         void g_test_message(const(char)* format, ...);
140         void g_test_bug_base(const(char)* uri_pattern);
141         void g_test_bug(const(char)* bug_uri_snippet);
142         void g_test_timer_start();
143         double g_test_timer_elapsed();
144         double g_test_timer_last();
145         void g_test_queue_free(gpointer gfree_pointer);
146         void g_test_queue_destroy(GDestroyNotify destroy_func, gpointer destroy_data);
147         gboolean g_test_trap_fork(guint64 usec_timeout, GTestTrapFlags test_trap_flags);
148         gboolean g_test_trap_has_passed();
149         gboolean g_test_trap_reached_timeout();
150         gint32 g_test_rand_int();
151         gint32 g_test_rand_int_range(gint32 begin, gint32 end);
152         double g_test_rand_double();
153         double g_test_rand_double_range(double range_start, double range_end);
154         GTestCase* g_test_create_case(const(char)* test_name, gsize data_size, gconstpointer test_data, GTestFixtureFunc data_setup, GTestFixtureFunc data_test, GTestFixtureFunc data_teardown);
155         GTestSuite* g_test_create_suite(const(char)* suite_name);
156         GTestSuite* g_test_get_root();
157         void g_test_suite_add(GTestSuite* suite, GTestCase* test_case);
158         void g_test_suite_add_suite(GTestSuite* suite, GTestSuite* nestedsuite);
159         int g_test_run_suite(GTestSuite* suite);
160         void g_test_trap_assertions(const(char)* domain, const(char)* file, int line, const(char)* func, guint64 assertion_flags, const(char)* pattern);
161         void g_assertion_message(const(char)* domain, const(char)* file, int line, const(char)* func, const(char)* message);
162         void g_assertion_message_expr(const(char)* domain, const(char)* file, int line, const(char)* func, const(char)* expr);
163         void g_assertion_message_cmpstr(const(char)* domain, const(char)* file, int line, const(char)* func, const(char)* expr, const(char)* arg1, const(char)* cmp, const(char)* arg2);
164         void g_assertion_message_cmpnum(const(char)* domain, const(char)* file, int line, const(char)* func, const(char)* expr, real arg1, const(char)* cmp, real arg2, char numtype);
165         void g_assertion_message_error(const(char)* domain, const(char)* file, int line, const(char)* func, const(char)* expr, const(GError)* error, GQuark error_domain, int error_code);
166         void g_test_add_vtable(const(char)* testpath, gsize data_size, gconstpointer test_data, GTestFixtureFunc data_setup, GTestFixtureFunc data_test, GTestFixtureFunc data_teardown);
167         const(char)* g_test_log_type_name(GTestLogType log_type);
168         GTestLogBuffer* g_test_log_buffer_new();
169         void g_test_log_buffer_free(GTestLogBuffer* tbuffer);
170         void g_test_log_buffer_push(GTestLogBuffer* tbuffer, guint n_bytes, const(guint8)* bytes);
171         GTestLogMsg* g_test_log_buffer_pop(GTestLogBuffer* tbuffer);
172         void g_test_log_msg_free(GTestLogMsg* tmsg);
173         void g_test_log_set_fatal_handler(GTestLogFatalFunc log_func, gpointer user_data);
174         void g_test_expect_message(const gchar *log_domain, GLogLevelFlags log_level, const gchar *pattern);
175         void g_test_assert_expected_messages_internal(const char *domain, const char *file, int line, const char *func);
176     }
177 }
178 else
179 {
180     extern( C ) nothrow 
181     {
182         alias da_g_strcmp0 = int function(const(char)* str1, const(char)* str2);																																				
183         alias da_g_test_minimized_result = void function(double minimized_quantity, const(char)* format, ...);																													
184         alias da_g_test_maximized_result = void function(double maximized_quantity, const(char)* format, ...);																													
185         alias da_g_test_init = void function(int* argc, char*** argv, ...);																																						
186         alias da_g_test_run = int function();																																													
187         alias da_g_test_add_func = void function(const(char)* testpath, GTestFunc test_func);																																	
188         alias da_g_test_add_data_func = void function(const(char)* testpath, gconstpointer test_data, GTestDataFunc test_func);	
189         alias da_g_test_add_data_func_full = void function(const char *testpath, gpointer test_data, GTestDataFunc test_func, GDestroyNotify data_free_func);
190         alias da_g_test_fail = void function();																																													
191         alias da_g_test_message = void function(const(char)* format, ...);																																						
192         alias da_g_test_bug_base = void function(const(char)* uri_pattern);																																						
193         alias da_g_test_bug = void function(const(char)* bug_uri_snippet);																																						
194         alias da_g_test_timer_start = void function();																																											
195         alias da_g_test_timer_elapsed = double function();																																										
196         alias da_g_test_timer_last = double function();																																											
197         alias da_g_test_queue_free = void function(gpointer gfree_pointer);																																						
198         alias da_g_test_queue_destroy = void function(GDestroyNotify destroy_func, gpointer destroy_data);																														
199         alias da_g_test_trap_fork = gboolean function(guint64 usec_timeout, GTestTrapFlags test_trap_flags);																													
200         alias da_g_test_trap_has_passed = gboolean function();																																									
201         alias da_g_test_trap_reached_timeout = gboolean function();																																								
202         alias da_g_test_rand_int = gint32 function();																																											
203         alias da_g_test_rand_int_range = gint32 function(gint32 begin, gint32 end);																																				
204         alias da_g_test_rand_double = double function();																																										
205         alias da_g_test_rand_double_range = double function(double range_start, double range_end);																																
206         alias da_g_test_create_case = GTestCase* function(const(char)* test_name, gsize data_size, gconstpointer test_data, GTestFixtureFunc data_setup, GTestFixtureFunc data_test, GTestFixtureFunc data_teardown);			
207         alias da_g_test_create_suite = GTestSuite* function(const(char)* suite_name);																																			
208         alias da_g_test_get_root = GTestSuite* function();																																										
209         alias da_g_test_suite_add = void function(GTestSuite* suite, GTestCase* test_case);																																		
210         alias da_g_test_suite_add_suite = void function(GTestSuite* suite, GTestSuite* nestedsuite);																															
211         alias da_g_test_run_suite = int function(GTestSuite* suite);																																							
212         alias da_g_test_trap_assertions = void function(const(char)* domain, const(char)* file, int line, const(char)* func, guint64 assertion_flags, const(char)* pattern);													
213         alias da_g_assertion_message = void function(const(char)* domain, const(char)* file, int line, const(char)* func, const(char)* message);																				
214         alias da_g_assertion_message_expr = void function(const(char)* domain, const(char)* file, int line, const(char)* func, const(char)* expr);																				
215         alias da_g_assertion_message_cmpstr = void function(const(char)* domain, const(char)* file, int line, const(char)* func, const(char)* expr, const(char)* arg1, const(char)* cmp, const(char)* arg2);					
216         alias da_g_assertion_message_cmpnum = void function(const(char)* domain, const(char)* file, int line, const(char)* func, const(char)* expr, real arg1, const(char)* cmp, real arg2, char numtype);						
217         alias da_g_assertion_message_error = void function(const(char)* domain, const(char)* file, int line, const(char)* func, const(char)* expr, const(GError)* error, GQuark error_domain, int error_code);					
218         alias da_g_test_add_vtable = void function(const(char)* testpath, gsize data_size, gconstpointer test_data, GTestFixtureFunc data_setup, GTestFixtureFunc data_test, GTestFixtureFunc data_teardown);					
219         alias da_g_test_log_type_name = const(char)* function(GTestLogType log_type);																																			
220         alias da_g_test_log_buffer_new = GTestLogBuffer* function();																																							
221         alias da_g_test_log_buffer_free = void function(GTestLogBuffer* tbuffer);																																				
222         alias da_g_test_log_buffer_push = void function(GTestLogBuffer* tbuffer, guint n_bytes, const(guint8)* bytes);																											
223         alias da_g_test_log_buffer_pop = GTestLogMsg* function(GTestLogBuffer* tbuffer);																																		
224         alias da_g_test_log_msg_free = void function(GTestLogMsg* tmsg);																																						
225         alias da_g_test_log_set_fatal_handler = void function(GTestLogFatalFunc log_func, gpointer user_data);																													
226         alias da_g_test_expect_message = void function(const gchar *log_domain, GLogLevelFlags log_level, const gchar *pattern);
227         alias da_g_test_assert_expected_messages_internal = void function(const char *domain, const char *file, int line, const char *func);
228     }
229 
230     __gshared
231     {
232         da_g_strcmp0 g_strcmp0; 
233         da_g_test_minimized_result g_test_minimized_result; 
234         da_g_test_maximized_result g_test_maximized_result; 
235         da_g_test_init g_test_init; 
236         da_g_test_run g_test_run; 
237         da_g_test_add_func g_test_add_func; 
238         da_g_test_add_data_func g_test_add_data_func; 
239         da_g_test_add_data_func_full g_test_add_data_func_full;
240         da_g_test_fail g_test_fail; 
241         da_g_test_message g_test_message; 
242         da_g_test_bug_base g_test_bug_base; 
243         da_g_test_bug g_test_bug; 
244         da_g_test_timer_start g_test_timer_start; 
245         da_g_test_timer_elapsed g_test_timer_elapsed; 
246         da_g_test_timer_last g_test_timer_last; 
247         da_g_test_queue_free g_test_queue_free; 
248         da_g_test_queue_destroy g_test_queue_destroy; 
249         da_g_test_trap_fork g_test_trap_fork; 
250         da_g_test_trap_has_passed g_test_trap_has_passed; 
251         da_g_test_trap_reached_timeout g_test_trap_reached_timeout; 
252         da_g_test_rand_int g_test_rand_int; 
253         da_g_test_rand_int_range g_test_rand_int_range; 
254         da_g_test_rand_double g_test_rand_double; 
255         da_g_test_rand_double_range g_test_rand_double_range; 
256         da_g_test_create_case g_test_create_case; 
257         da_g_test_create_suite g_test_create_suite; 
258         da_g_test_get_root g_test_get_root; 
259         da_g_test_suite_add g_test_suite_add; 
260         da_g_test_suite_add_suite g_test_suite_add_suite; 
261         da_g_test_run_suite g_test_run_suite; 
262         da_g_test_trap_assertions g_test_trap_assertions; 
263         da_g_assertion_message g_assertion_message; 
264         da_g_assertion_message_expr g_assertion_message_expr; 
265         da_g_assertion_message_cmpstr g_assertion_message_cmpstr; 
266         da_g_assertion_message_cmpnum g_assertion_message_cmpnum; 
267         da_g_assertion_message_error g_assertion_message_error; 
268         da_g_test_add_vtable g_test_add_vtable; 
269         da_g_test_log_type_name g_test_log_type_name; 
270         da_g_test_log_buffer_new g_test_log_buffer_new; 
271         da_g_test_log_buffer_free g_test_log_buffer_free; 
272         da_g_test_log_buffer_push g_test_log_buffer_push; 
273         da_g_test_log_buffer_pop g_test_log_buffer_pop; 
274         da_g_test_log_msg_free g_test_log_msg_free; 
275         da_g_test_log_set_fatal_handler g_test_log_set_fatal_handler;
276         da_g_test_expect_message g_test_expect_message;
277         da_g_test_assert_expected_messages_internal g_test_assert_expected_messages_internal;
278     }
279 }